Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: goroutine leak with docker daemon #183

Merged
merged 4 commits into from
Jul 27, 2023

Conversation

iAklis
Copy link
Contributor

@iAklis iAklis commented May 25, 2023

This commit addresses a goroutine leak that occurs when continuously communicating with the Docker daemon via the Unix socket. Previously, these connections were not being properly released, leading to a growing number of goroutines over time.

The first solution with 4cf42ac involved modifying the http.Transport of the Docker client to disable keep-alives and set an idle connection timeout. This effectively closes idle connections, thereby preventing the goroutine leak.

Based off of comments on the issue this was pivoted to close the client after the provider is used for the first time.

Resolves: #182

@iAklis iAklis changed the title This commit addresses a goroutine leak that occurs when continuously … fix: goroutine leak keepalive with docker daemon Jun 16, 2023
@wagoodman
Copy link
Contributor

wagoodman commented Jul 24, 2023

Hey @iAklis I updated the PR based on feedback in the issue -- that being said, you can treat this as a suggested path... if you don't like this approach we can chat further. Does the branch with the current adjustments also fix the behavior you're seeing?

(I also force pushed to rebase the branch on main)

iAklis and others added 2 commits July 24, 2023 11:54
…communicating with the Docker daemon via the Unix socket. Previously, these connections were not being properly released, leading to a growing number of goroutines over time.

The solution involves modifying the http.Transport of the Docker client to disable keep-alives and set an idle connection timeout. This effectively closes idle connections, thereby preventing the goroutine leak.

Changes made:
- Added `DisableKeepAlives: true` and `IdleConnTimeout:   10 * time.Second` to the http.Transport of the Docker client.

Resolves: anchore#182

Signed-off-by: Aklis Chen <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
@iAklis
Copy link
Contributor Author

iAklis commented Jul 25, 2023

@wagoodman Yes, it works.

@wagoodman wagoodman changed the title fix: goroutine leak keepalive with docker daemon fix: goroutine leak with docker daemon Jul 25, 2023
@wagoodman wagoodman enabled auto-merge (squash) July 25, 2023 13:26
@wagoodman wagoodman self-assigned this Jul 25, 2023
@wagoodman wagoodman disabled auto-merge July 27, 2023 21:19
@wagoodman wagoodman merged commit d1f3d76 into anchore:main Jul 27, 2023
11 checks passed
@iAklis iAklis deleted the fix-goroutine-leak branch July 31, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Goroutine Leak in Long-Running Services with Stereoscope
2 participants